<template lang="pug">
  Form(ref='basicData',:model='basicAttrData',:rules='ruleValidate',:label-width='160', style='width:800px')
    FormItem(label='模型类型：', prop='modelType')
      Select(v-model='basicAttrData.modelType')
        Option(v-for='(modeList,index) in modelTypeLists',:value='modeList.itemType',:key='index') {{modeList.itemName}}
    FormItem(label='内容提供方式：', prop='contentType')
      Select(v-model='basicAttrData.contentType')
        Option(v-for='(contentList,index) in contentTypeLists',:value='contentList.itemType',:key='index') {{contentList.itemName}}
    FormItem(label='模型正则表达式：', prop='modelRegularExpression')
      Input(v-model='basicAttrData.modelRegularExpression', type='textarea', :autosize='{minRows: 4,maxRows: 5}', :maxlength='500')
    FormItem(label='允许爬行URL正则：', prop='urlsAllowCrawlRegex')
      Input(v-model='basicAttrData.urlsAllowCrawlRegex', type='textarea', :autosize='{minRows: 4,maxRows: 5}', :maxlength='500')
    FormItem(label='不允许爬行URL正则：', prop='urlsNotAllowCrawlRegex')
      Input(v-model='basicAttrData.urlsNotAllowCrawlRegex', type='textarea', :autosize='{minRows: 4,maxRows: 5}', :maxlength='500')
    FormItem(label='登录：', prop='needLogin')
      RadioGroup(v-model='basicAttrData.needLogin')
        Radio(:label='1') 是
        Radio(:label='0') 否
    FormItem(label='抽取url：')
      RadioGroup(v-model='basicAttrData.urlExtractable')
        Radio(:label='1') 是
        Radio(:label='0') 否
      aside(v-if='basicAttrData.urlExtractable === 1').mould-urltype
        Select(v-model='basicAttrData.urlExtractRuleType')
          Option(v-for='item in extractTypeLists', :value='item.itemType', :key='item.itemName') {{item.itemName}}
        Input(v-model='basicAttrData.urlExtractRule', :maxlength='200')
    FormItem(label='浏览器采集：', prop='browserCrawlable')
      RadioGroup(v-model='basicAttrData.browserCrawlable')
        Radio(:label='2') 是
        Radio(:label='1') 否
      .browser-specific_con(v-if="basicAttrData.browserCrawlable===2").browser-specific
        .browser-specific_item
          label 刷新方式：
          Select(v-model='browserParameter.refreshType')
            Option(v-for='(val,index) in refreshTypeLists',:value='val.itemType',:key='val.itemName') {{val.itemName}}
        .browser-specific_item
          label 最大下拉次数：
          Select(v-model='browserParameter.maxDropDownNum')
            Option(v-for='(val,index) in maxDropDownNumList',:value='val.itemType',:key='val.itemName') {{val.itemName}}
        .browser-specific_item
          label 元素刷新定位规格（xpath格式）：
          Input(v-model='browserParameter.eleLocateRule', type='textarea', :autosize='{minRows: 3,maxRows: 5}', :maxlength='200')
        .browser-specific_item
          label 页面加载完成元素判断规则（xpath格式）：
          Input(v-model='browserParameter.loadFinishedDecisionRule', type='textarea', :autosize='{minRows: 3,maxRows: 5}', :maxlength='200')
        .browser-specific_item
          label 页面js注入：
          Input(v-model='browserParameter.injectJS', type='textarea', :autosize='{minRows: 3,maxRows: 5}', :maxlength='20000')
        .browser-specific_item
          label(style='width: 126px;') 是否刷新：
          RadioGroup(v-model='browserParameter.refreshable')
            Radio(:label='1') 是
            Radio(:label='0') 否
        .browser-specific_item
          label 刷新等待时间：
          Select(v-model='browserParameter.refreshWaitTime')
            Option(v-for='(val,index) in refreshWaitTimeList',:value='val.itemType',:key='val.itemName') {{val.itemName}}
    FormItem(label='翻页：', prop='pageTurningable')
      RadioGroup(v-model='basicAttrData.pageTurningable')
        Radio(:label='1') 是
        Radio(:label='0') 否
      aside(v-if='basicAttrData.pageTurningable === 1').turn-page
        .turn-page_item
          label 翻页方式：
          Select(v-model='pageTurningParameter.pageTurningType')
            Option(:value='1') 直接抽取下一页连接
            Option(:value='2') 自动生成URL连接
        .turn-page_item
          label 抽取规则：
          Select(v-model='pageTurningParameter.extractType')
            Option(v-for='(val,index) in extractTypeLists',:value='val.itemType',:key='val.itemName') {{val.itemName}}
        .turn-page_item
          label 抽取规则表达式：
          Input(v-model='pageTurningParameter.extractRule', type='textarea', :autosize='{minRows: 3,maxRows: 5}', :maxlength='500')
        .turn-page_item
          label 下一页表达式：
          Input(v-model='pageTurningParameter.pageDownExpression', type='textarea', :autosize='{minRows: 3,maxRows: 5}', :maxlength='500')
</template>

<script>
import { asyncMould } from '../../api'
export default {
  props: {
    modelTypeLists: { type: Array },
    extractTypeLists: { type: Array },
    contentTypeLists: { type: Array },
    refreshTypeLists: { type: Array }
  },
  data() {
    return {
      basicAttrData: {
        modelType: '',
        contentType: '',
        modelRegularExpression: '',
        urlsAllowCrawlRegex: '',
        urlsNotAllowCrawlRegex: '',
        needLogin: 0,
        urlExtractable: 0,
        urlExtractRuleType: '',
        urlExtractRule: '',
        browserCrawlable: 1,
        pageTurningable: 0
      },
      ruleValidate: {
        modelRegularExpression: [{ required: true, message: '请输入模型正则表达式', trigger: 'blur' }]
      },
      browserParameter: {
        refreshType: '',
        maxDropDownNum: 1,
        eleLocateRule: '',
        loadFinishedDecisionRule: '',
        injectJS: '',
        refreshable: 0,
        refreshWaitTime: 3
      },
      pageTurningParameter: {
        pageTurningType: 1,
        extractType: 1,
        extractRule: ' ',
        pageDownExpression: ''
      },
      maxDropDownNumList: [
        { itemType: 1, itemName: '1次' },
        { itemType: 5, itemName: '5次' },
        { itemType: 10, itemName: '10次' },
        { itemType: 20, itemName: '20次' },
        { itemType: 30, itemName: '30次' },
        { itemType: 50, itemName: '50次' },
        { itemType: 100, itemName: '100次' }
      ],
      refreshWaitTimeList: [
        { itemType: 3, itemName: '3秒' },
        { itemType: 5, itemName: '5秒' },
        { itemType: 10, itemName: '10秒' },
        { itemType: 30, itemName: '30秒' },
        { itemType: 60, itemName: '60秒' },
        { itemType: 120, itemName: '120秒' },
        { itemType: 300, itemName: '300秒' }
      ]
    }
  }
}
</script>

